﻿
Imports System.IO
Imports std
Imports xmlctrl
Imports xhtmlctrl

Public Class ie8acceleratorInstaller
    Public Const functionName As String = "ie8accIns"

    Public Shared Sub invoke(ByVal inlineScript As inlineScript, ByVal link As String, ByRef actionTarget As String)
        assert(Not inlineScript Is Nothing, "inlineScript is nothing.")
        inlineScript.addscript(network.http.contentType.textjavascript, "ie8accelerator" _
                               , "function " + functionName + "(link){window.external.addService(link);}")
        actionTarget += functionName + "(" + link + ")"
    End Sub
End Class

Public Class ie8acceleratorInstalled
    Public Const functionName As String = "ie8accInst"

    Public Shared Sub invoke(ByVal inlineScript As inlineScript, ByRef actionTarget As String, ByVal action As String _
                             , ByVal site As String, ByVal category As String _
                             , Optional ByVal elseAction As String = Nothing)
        assert(Not inlineScript Is Nothing, "inlineScript is nothing.")
        assert(Not IsNothing(action), "action is an empty string.")
        assert(Not IsNothing(site), "site is an empty string.")
        assert(Not IsNothing(category), "category is an empty string.")
        Dim ifelseAction As String = Nothing
        ifelse.invoke("window.external.IsServiceInstalled(site,cat)", action, elseAction, ifelseAction)
        Dim script As String = Nothing
        script = "function " + functionName + "(site,cat){" + ifelseAction + "}"
        inlineScript.addscript(network.http.contentType.textjavascript, "ie8acceleratorInstalled", script)
        actionTarget += functionName + "(" + site + "," + category + ")"
    End Sub
End Class

Public Class ie8acceleratorInstallerInfo
    Implements ICloneable

    Public name As String = Nothing
    Public desctiption As String = Nothing
    Public acc As String = Nothing
    Public filename As String = Nothing
    Public category As String = Nothing
    Public icon As String = Nothing

#If RETIRED Then
    Public Sub New()
    End Sub

    Public Sub New(ByVal iName As String _
                   , ByVal iDes As String _
                   , ByVal iAcc As String _
                   , ByVal iFile As String _
                   , ByVal iCat As String _
                   , Optional ByVal iIcon As String = nothing)
        copy(name, iName)
        copy(desctiption, iDes)
        copy(acc, iAcc)
        copy(filename, iFile)
        copy(category, iCat)
        copy(icon, iIcon)
    End Sub
#End If

    Public Function Clone() As Object Implements System.ICloneable.Clone
        Dim rtn As ie8acceleratorInstallerInfo = Nothing
        rtn = New ie8acceleratorInstallerInfo()

        copy(rtn.name, name)
        copy(rtn.desctiption, desctiption)
        copy(rtn.acc, acc)
        copy(rtn.filename, filename)
        copy(rtn.category, category)
        copy(rtn.icon, icon)

        Return rtn
    End Function
End Class

Public Class ie8acceleratorInfo
    Implements ICloneable

    Public Class parameter
        Implements ICloneable

        Public Const documentUrl As String = "{documentUrl}"
        Public Const link As String = "{link}"

        Public Const text As String = "text"

        Public name As String = Nothing
        Public value As String = Nothing
        Public type As String = Nothing

        Public Function Clone() As Object Implements System.ICloneable.Clone
            Dim rtn As parameter = Nothing
            rtn = New parameter()
            copy(rtn.name, name)
            copy(rtn.value, value)
            copy(rtn.type, type)

            Return rtn
        End Function
    End Class

    Public Class execute
        Implements ICloneable

        Public method As String = Nothing
        Public actionPath As String = Nothing
        Public parameters As vector(Of parameter) = Nothing

        Public Sub New()
            parameters = New vector(Of parameter)()
        End Sub

        Public Function Clone() As Object Implements System.ICloneable.Clone
            Dim rtn As execute = Nothing
            rtn = New execute()

            copy(rtn.method, method)
            copy(rtn.actionPath, actionPath)
            copy(rtn.parameters, parameters)

            Return rtn
        End Function
    End Class

    Public Class action
        Implements ICloneable

        Public Const document As String = "document"
        Public Const link As String = "link"
        Public Const selection As String = "selection"

        Public context As String = Nothing
        Public executes As vector(Of execute) = Nothing

        Public Sub New()
            executes = New vector(Of execute)()
        End Sub

        Public Function Clone() As Object Implements System.ICloneable.Clone
            Dim rtn As action = Nothing
            rtn = New action()

            copy(rtn.context, context)
            copy(rtn.executes, executes)

            Return rtn
        End Function
    End Class

    Public Class activity
        Implements ICloneable

        Public category As String = Nothing
        Public actions As vector(Of action) = Nothing

        Public Sub New()
            actions = New vector(Of action)()
        End Sub

        Public Function Clone() As Object Implements System.ICloneable.Clone
            Dim rtn As activity = Nothing
            rtn = New activity()

            copy(rtn.category, category)
            copy(rtn.actions, actions)

            Return rtn
        End Function
    End Class

    Public name As String = Nothing
    Public icon As String = Nothing
    Public description As String = Nothing
    Public activities As vector(Of activity) = Nothing

    Public Sub New()
        activities = New vector(Of activity)()
    End Sub

    Public Function Clone() As Object Implements System.ICloneable.Clone
        Dim rtn As ie8acceleratorInfo = Nothing
        rtn = New ie8acceleratorInfo()

        copy(rtn.name, name)
        copy(rtn.icon, icon)
        copy(rtn.description, description)
        copy(rtn.activities, activities)

        Return rtn
    End Function
End Class

#If RETIRED Then
Public Class ie8accExecute
    Inherits xmlcontrol

    Public Sub New(Optional Byval buff As MemoryStream = Nothing)
        MyBase.New(buff, "execute")
    End Sub

    Protected Overrides Function renderAttributes(ByVal compress As Boolean) As Boolean
        Return renderAttributesImpl(compress, "method", "action")
    End Function
End Class

Public Class ie8accParameter
    Inherits xmlcontrol

    Public Sub New(Optional Byval buff As MemoryStream = Nothing)
        MyBase.New(buff, "parameter")
    End Sub

    Protected Overrides Function renderAttributes(ByVal compress As Boolean) As Boolean
        Return renderAttributesImpl(compress, "name", "value")
    End Function
End Class
#End If
